package com.grass.p019lv.adapter;

import android.graphics.Color;
import android.text.Spannable;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.bean.NoticeBean;
import com.androidx.p013lv.base.recycler.BaseRecyclerAdapter;
import com.androidx.p013lv.base.recycler.BaseRecyclerHolder;
import com.androidx.p013lv.base.utils.TimeUtils;

/* renamed from: com.grass.lv.adapter.NotificationAdapter */
public class NotificationAdapter extends BaseRecyclerAdapter<NoticeBean, ViewHolder> {
    public void MyHolder(ViewHolder viewHolder, int i) {
        viewHolder.setData((NoticeBean) getDataInPosition(i));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_notification_layout, viewGroup, false));
    }

    /* renamed from: com.grass.lv.adapter.NotificationAdapter$ViewHolder */
    public class ViewHolder extends BaseRecyclerHolder {
        TextView tv_content;
        TextView tv_time;
        TextView tv_title;

        ViewHolder(View view) {
            super(view);
            this.tv_title = (TextView) view.findViewById(R.id.tv_title);
            this.tv_content = (TextView) view.findViewById(R.id.tv_content);
            this.tv_time = (TextView) view.findViewById(R.id.tv_time);
        }

        /* access modifiers changed from: package-private */
        public void setData(NoticeBean noticeBean) {
            this.tv_title.setText(noticeBean.getName());
            this.tv_content.setText(noticeBean.getContent());
            this.tv_time.setText(TimeUtils.utcToChina(noticeBean.getCreatedAt()));
            NotificationAdapter.this.stripUnderlines(this.tv_content);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void stripUnderlines(TextView textView) {
        if (textView != null && (textView.getText() instanceof Spannable)) {
            Spannable spannable = (Spannable) textView.getText();
            URLSpan[] uRLSpanArr = (URLSpan[]) spannable.getSpans(0, spannable.length(), URLSpan.class);
            for (URLSpan uRLSpan : uRLSpanArr) {
                int spanStart = spannable.getSpanStart(uRLSpan);
                int spanEnd = spannable.getSpanEnd(uRLSpan);
                spannable.removeSpan(uRLSpan);
                spannable.setSpan(new URLSpanNoUnderline(uRLSpan.getURL()), spanStart, spanEnd, 0);
            }
            textView.setAutoLinkMask(0);
            textView.setText(spannable);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: com.grass.lv.adapter.NotificationAdapter$URLSpanNoUnderline */
    public static class URLSpanNoUnderline extends URLSpan {
        static final /* synthetic */ boolean $assertionsDisabled = false;

        URLSpanNoUnderline(String str) {
            super(str);
        }

        public void updateDrawState(TextPaint textPaint) {
            super.updateDrawState(textPaint);
            textPaint.setColor(Color.parseColor("#7774FD"));
            textPaint.setUnderlineText(false);
        }
    }
}
